// 列表分页
import Util from '@/utils/test.js'
const state = {
  paginate: {
    currentPage: 1,
    lastPage: 1,
    listRows: 5,
    total: 1,
    hidePage: true
  }
}

const mutations = {
  SET_PAGINATE: (state, paginate) => {
    var _paginate = state.paginate
    Util.extend(_paginate, paginate)
    state.paginate = _paginate
  },
  SET_PAGINATE_DEFAULT: state => {
    state.paginate = {
      currentPage: 1,
      lastPage: 1,
      listRows: 5,
      total: 1,
      hidePage: true
    }
  }
}

const actions = {
  setPaginate({ commit }, paginate) {
    commit('SET_PAGINATE', paginate)
  }
}

const getters = {
  page: state => state.paginate.currentPage,
  count: state => state.paginate.listRows
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
